﻿using System.Collections.Generic;
using Cygida.Environment.DataAccess;
using WallpaperSharing.DataAccess.Interfaces;
using WallpaperSharing.Domain;

namespace WallpaperSharing.DataAccess
{
    public class CategoryDao : DaoBase, ICategoryDao
    {
        public CategoryDao()
            : this(DataSources.Manhattan)
        { }

        public CategoryDao(IBaseDataSource dataSource)
            : base(dataSource)
        { }

        public IList<Category> SelectAll()
        {
            return DataSource.QueryForList<Category>("SelectAllCategories", null);
        }

        public Category SelectById(int id)
        {
            return DataSource.QueryForObject<Category>("SelectCategoryById", id);
        }

        public IList<Category> SelectByWallpaperId(int wallpaperId)
        {
            return DataSource.QueryForList<Category>("SelectCategoriesByWallpaperId", wallpaperId);
        }

        public void Insert(Category domain)
        {
            DataSource.Insert("InsertCategory", domain);
        }

        public void Update(Category domain)
        {
            DataSource.Update("UpdateCategory", domain);
        }

        public void Delete(int id)
        {
            DataSource.Delete("DeleteCategory", id);
        }
    }
}
